<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>爬取数据中</title>
    <link rel="stylesheet" type="text/css"
          href="http://xcdn.php.cn/js/CSS3/%E7%BA%AFcss3%E7%BD%91%E9%A1%B5loading%E9%A2%84%E5%8A%A0%E8%BD%BD%E5%8A%A8%E7%94%BB%E7%89%B9%E6%95%88/css/style-10.css"/>
    <style>
        a {
            background: #13A3A5;
            padding: 5px;
            margin: 10px;
            display: block;
            font-weight: 100;
            cursor: pointer;
            font-size: 1.5em;
            float: left;
            text-decoration: none;
            font-size: 18px;
            color: white
        }
    </style>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div style="margin: 80px auto;width: 100px;">
    <h2></h2>
</div>
<div class="loader">
    <div>正</div>
    <div>在</div>
    <div>爬</div>
    <div>取</div>
    <div>数</div>
    <div>据</div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
</body>
<script>
    function start() {
        var name="{{taobao_name}}";
        var taobao_pwd="{{taobao_pwd}}";
        console.log(name);
        console.log(taobao_pwd);
        axios({
          method: 'post',
          url: '/startPachou',
          data: {
            taobao_name: "{{taobao_name}}",
            taobao_pwd: "{{taobao_pwd}}",
          }
        });
    }
    function setTimer() {
        let timer;
        axios.post("/getStatus")
            .then(function (res) {
                if (res) {
                    console.log(res);
                    if (res.data=='False'){
                        window.location.href="http://127.0.0.1:8000/";
                        clearTimeout(timer) //清理定时任务
                        return;
                    }
                    timer = setTimeout(() => {
                        this.setTimer()
                    }, 5000)
                } else {
                    clearTimeout(timer) //清理定时任务
                }

            })
            .catch(function (error) {
                console.log(error);
            });
    }
    start();
    setTimer();
</script>
</html>
